home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / ansi / sparc / math.h < prev    next >
C/C++ Source or Header  |  1994-09-14  |  4KB  |  109 lines

  1. /* Copyright (c) 1992 NeXT Computer, Inc.  All rights reserved.
  2.  *
  3.  *    File:    <ansi/sparc/math.h>
  4.  */
  5.  
  6.  
  7. /*
  8.  * Constants.
  9.  */
  10.  
  11. //#define    HUGE_VAL    (__infinity())    /* Produces IEEE Infinity. */
  12. #define    HUGE_VAL    (1e999)
  13.  
  14. #ifndef __STRICT_ANSI__
  15.  
  16. //#define    HUGE        (infinity())    /* For historical compatibility. */
  17. #define    HUGE        HUGE_VAL
  18. #define NAN    (HUGE/HUGE)    /*FIXME: not in sun sources */
  19.  
  20. /* These values work with any binary representation of integers
  21.  * where the high-order bit contains the sign. */
  22.  
  23. /* a number used normally for size of a shift */
  24. #define BITSPERBYTE    8
  25. #define BITS(type)    (BITSPERBYTE * (int)sizeof(type))
  26.  
  27. /* short, regular and long ints with only the high-order bit turned on */
  28. #define HIBITS    ((short)(1 << BITS(short) - 1))
  29. #define HIBITI    (1 << BITS(int) - 1)
  30. #define HIBITL    (1L << BITS(long) - 1)
  31.  
  32. /* largest short, regular and long int */
  33. #define MAXSHORT    ((short)~HIBITS)
  34. #define MAXINT    (~HIBITI)
  35. #define MAXLONG    (~HIBITL)
  36. #define MAXCHAR ((char)0x7f)    /*FIXME: not in sun sources */
  37.  
  38. #define MINCHAR ((char)0x80)    /*FIXME: not in sun sources */
  39. #define MINSHORT ((short)0x8000)    /*FIXME: not in sun sources */
  40. #define MININT     ((int)0x80000000)    /* max negative 32-bit integer */    /*FIXME: not in sun sources */
  41. #define MINLONG ((long)0x80000000)    /*FIXME: not in sun sources */
  42.  
  43. /* various values that describe the binary floating-point representation
  44.  * _EXPBASE    - the exponent base
  45.  * DMAXEXP     - the maximum exponent of a double (as returned by frexp())
  46.  * FMAXEXP     - the maximum exponent of a float  (as returned by frexp())
  47.  * DMINEXP     - the minimum exponent of a double (as returned by frexp())
  48.  * FMINEXP     - the minimum exponent of a float  (as returned by frexp())
  49.  * MAXDOUBLE    - the largest double
  50.             ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
  51.  * MAXFLOAT    - the largest float
  52.             ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
  53.  * MINDOUBLE    - the smallest double (_EXPBASE ** (DMINEXP - 1))
  54.  * MINFLOAT    - the smallest float (_EXPBASE ** (FMINEXP - 1))
  55.  * DSIGNIF    - the number of significant bits in a double
  56.  * FSIGNIF    - the number of significant bits in a float
  57.  * DMAXPOWTWO    - the largest power of two exactly representable as a double
  58.  * FMAXPOWTWO    - the largest power of two exactly representable as a float
  59.  * _IEEE    - 1 if IEEE standard representation is used
  60.  * _DEXPLEN    - the number of bits for the exponent of a double
  61.  * _FEXPLEN    - the number of bits for the exponent of a float
  62.  * _HIDDENBIT    - 1 if high-significance bit of mantissa is implicit
  63.  * LN_MAXDOUBLE    - the natural log of the largest double  -- log(MAXDOUBLE)
  64.  * LN_MINDOUBLE    - the natural log of the smallest double -- log(MINDOUBLE)
  65.  * LN_MAXFLOAT    - the natural log of the largest float  
  66.  * LN_MINFLOAT    - the natural log of the smallest float
  67.  */
  68. #define MAXDOUBLE    1.797693134862315708e+308
  69. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  70. #define MINDOUBLE    4.94065645841246544e-324
  71. #define MINFLOAT    ((float)1.40129846432481707e-45)
  72. #define    _IEEE        1
  73. #define _DEXPLEN    11
  74. #define _HIDDENBIT    1
  75. #define DMINEXP    (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  76. #define FMINEXP    (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  77. #define LN_MAXFLOAT    8.8722839052068e+01
  78. #define LN_MINFLOAT    -1.03278929903432e+02
  79. #define _LENBASE    1
  80. #define _EXPBASE    (1 << _LENBASE)
  81. #define _FEXPLEN    8
  82. #define DSIGNIF    (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
  83. #define FSIGNIF    (BITS(float)  - _FEXPLEN + _HIDDENBIT - 1)
  84. #define DMAXPOWTWO    ((double)(1L << BITS(long) - 2) * \
  85.                 (1L << DSIGNIF - BITS(long) + 1))
  86. #define FMAXPOWTWO    ((float)(1L << FSIGNIF - 1))
  87. #define DMAXEXP    ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  88. #define FMAXEXP    ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  89. #define LN_MAXDOUBLE    (M_LN2 * DMAXEXP)
  90. #define LN_MINDOUBLE    (M_LN2 * (DMINEXP - 1))
  91.  
  92. #define    M_LN2    0.69314718055994530942
  93. #define    M_PI    3.14159265358979323846
  94. #define    M_SQRT2    1.41421356237309504880
  95.  
  96. #define    M_E        2.7182818284590452354
  97. #define    M_LOG2E        1.4426950408889634074
  98. #define    M_LOG10E    0.43429448190325182765
  99. #define    M_LN10        2.30258509299404568402
  100. #define    M_PI_2        1.57079632679489661923
  101. #define    M_PI_4        0.78539816339744830962
  102. #define    M_1_PI        0.31830988618379067154
  103. #define    M_2_PI        0.63661977236758134308
  104. #define    M_2_SQRTPI    1.12837916709551257390
  105. #define    M_SQRT1_2    0.70710678118654752440
  106.  
  107.  
  108. #endif /* __STRICT_ANSI__ */
  109.